/*
 * pointrank.h
 *
 *  Created on: May 6, 2014
 *      Author: killerg
 */

#ifndef POINTRANK_H_
#define POINTRANK_H_

#include "player_mgr.h"

struct pointrank_t {
	struct member_t {
		int64_t id = -1;
		int64_t points = 0;
		int32_t win_con = 0;
		sp_player_t stub;
	};

	struct group_t {
		vector<member_t> members;
		string last_win;
		int32_t update_count = 0;
	};

	vector<group_t> groups;
	int32_t finish = -1;
	set<int32_t> pet_family;

	int change_count = 0;
	int rewarding_group = -1;
	int rewarding_index = -1;
};

bool pointrank_init(pointrank_t* pr);
void pointrank_destroy(pointrank_t* pr);
void pointrank_update(pointrank_t* pr);
void pointrank_reset(pointrank_t* pr);

pointrank_t* pointrank_create();
void pointrank_delete(pointrank_t* pr);
void pointrank_init(pointrank_t* pr, const Json::Value &json);
void pointrank_save(pointrank_t* pr, Json::Value &json);
void pointrank_print(pointrank_t* pr);
int pointrank_get_member(pointrank_t* pr, int64_t playerid, pointrank_t::member_t* &mem, int &group);
bool pointrank_checkpets(pointrank_t* pr, sp_player_t player);
int pointrank_get_member_num(pointrank_t* pr, int group = -1);

#endif /* POINTRANK_H_ */
